<template>
  <p>孙子组件2</p>
  <p>{{ info }}</p>
</template>

<script setup>
import emitter from "@/utils/eventBus";
import { ref, onMounted, onBeforeUnmount } from "vue";
const info = ref("");
onMounted(() => {
  emitter.on("myEvent", (res) => {
    console.log("info.value: ", res);
    info.value = res;
  });
});
onBeforeUnmount(() => {
  console.log("onBeforeUnmount");
  emitter.off("myEvent");
});
</script>

<style lang="scss" scoped></style>
